/*
 * intnumberobject.cpp
 *
 *  Created on: Oct 27, 2009
 *      Author: price
 */

#include "includes/intnumberobject.h"
namespace templatipus {

TIntNumberObject::TIntNumberObject() :
	TNumberObject(), internalValue(0) {

}

TIntNumberObject::TIntNumberObject(const TemplateObject &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const int8 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const int16 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const int32 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const int64 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const float32 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const float64 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TIntNumberObject::TIntNumberObject(const std::wstring& rhs) :
	TNumberObject(rhs) {
	swscanf(rhs.c_str(), WPRINTF_INT64_MODIFIER, &this->internalValue);
}

TIntNumberObject::TIntNumberObject(const std::string& rhs) :
	TNumberObject(rhs) {
	sscanf(rhs.c_str(), PRINTF_INT64_MODIFIER, &this->internalValue);
}

TIntNumberObject::TIntNumberObject(const unicodePtr rhs) :
	TNumberObject(rhs) {
	swscanf(rhs, WPRINTF_INT64_MODIFIER, &this->internalValue);
}

TIntNumberObject::TIntNumberObject(const utf8Ptr rhs) :
	TNumberObject(rhs) {
	sscanf(rhs, PRINTF_INT64_MODIFIER, &this->internalValue);
}

TIntNumberObject::~TIntNumberObject() {

}

TIntNumberObject TIntNumberObject::operator +(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result += other;
	return result;
}
TIntNumberObject TIntNumberObject::operator -(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result -= other;
	return result;
}

TIntNumberObject TIntNumberObject::operator *(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result *= other;
	return result;
}

TIntNumberObject TIntNumberObject::operator /(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result /= other;
	return result;
}
TIntNumberObject TIntNumberObject::operator %(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result %= other;
	return result;
}
TIntNumberObject TIntNumberObject::operator &(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result &= other;
	return result;
}
TIntNumberObject TIntNumberObject::operator |(const TemplateObject &other) {
	TIntNumberObject result = *this;
	result |= other;
	return result;
}

const TemplateObject& TIntNumberObject::operator ++() {
	this->internalValue++;
	return *this;
}

const TemplateObject& TIntNumberObject::operator --() {
	this->internalValue--;
	return *this;
}

const TemplateObject& TIntNumberObject::operator +=(const TemplateObject &other) {
	this->internalValue += ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator -=(const TemplateObject &other) {
	this->internalValue -= ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator *=(const TemplateObject &other) {
	this->internalValue *= ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator /=(const TemplateObject &other) {
	this->internalValue /= ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator %=(const TemplateObject &other) {
	this->internalValue %= ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator &=(const TemplateObject &other) {
	this->internalValue &= ((int64) other);
	return *this;
}

const TemplateObject& TIntNumberObject::operator |=(const TemplateObject &other) {
	this->internalValue |= ((int64) other);
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const TemplateObject &other) {
	if (this != &other) {
		this->internalValue = (int64) other;
	}
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const int8 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const int16 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const int32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const int64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const float32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const float64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const std::wstring &other) {
	swscanf(other.c_str(), WPRINTF_INT64_MODIFIER, &this->internalValue);
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const std::string &other) {
	sscanf(other.c_str(), PRINTF_INT64_MODIFIER, &this->internalValue);
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const unicodePtr other) {
	swscanf(other, WPRINTF_INT64_MODIFIER, &this->internalValue);
	return *this;
}

TemplateObject& TIntNumberObject::operator=(const utf8Ptr other) {
	sscanf(other, PRINTF_INT64_MODIFIER, &this->internalValue);
	return *this;
}

tbool TIntNumberObject::operator ==(const TemplateObject &other) const {
	return (this->internalValue == (int64) other);
}

tbool TIntNumberObject::operator !=(const TemplateObject &other) const {
	return !(*this == other);
}

tbool TIntNumberObject::operator >(const TemplateObject &other) const {
	return (this->internalValue > (int64) other);
}

tbool TIntNumberObject::operator <(const TemplateObject &other) const {
	return !(*this > other);
}

tbool TIntNumberObject::operator >=(const TemplateObject &other) const {
	return (this->internalValue >= (int64) other);
}

tbool TIntNumberObject::operator <=(const TemplateObject &other) const {
	return !(*this >= other);
}

tbool TIntNumberObject::operator &&(const TemplateObject &other) const {
	return (this->internalValue && (tbool)other);
}

tbool TIntNumberObject::operator ||(const TemplateObject &other) const {
	return (this->internalValue || (tbool)other);
}

TIntNumberObject::operator std::string() const {
	std::ostringstream result;
	result << this->internalValue;
	return result.str();
}
TIntNumberObject::operator std::wstring() const {
	std::wostringstream result;
	result << this->internalValue;
	return result.str();
}

//Conversion operators
//Number
TIntNumberObject::operator int8() const {
	return this->internalValue;
}
TIntNumberObject::operator uint8() const {
	return (uint8) this->internalValue;
}
TIntNumberObject::operator int16() const {
	return (int16) this->internalValue;
}
TIntNumberObject::operator uint16() const {
	return (uint16) this->internalValue;
}
TIntNumberObject::operator int32() const {
	return (int32) this->internalValue;
}
TIntNumberObject::operator uint32() const {
	return (uint32) this->internalValue;
}
TIntNumberObject::operator int64() const {
	return (int64) this->internalValue;
}
TIntNumberObject::operator uint64() const {
	return (uint64) this->internalValue;
}
TIntNumberObject::operator float32() const {
	return (float32) this->internalValue;
}
TIntNumberObject::operator float64() const {
	return (float64) this->internalValue;
}

TIntNumberObject::operator tbool() const {
	return (tbool) this->internalValue;
}
}
